package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.bean.WorkPartFeedbackResponse;
import com.cloudsigns.factorymanager2.produce.iview.IProductFeedbackListView1;
import com.cloudsigns.factorymanager2.produce.model.IProductFeedbackListModel1;
import com.cloudsigns.factorymanager2.produce.model.ProductFeedbackListModel1;

import java.util.List;

public class ProductFeedbackListPresenter1 {
    private IProductFeedbackListView1 view;
    private IProductFeedbackListModel1 model;
    private Handler handler = new Handler();

    public ProductFeedbackListPresenter1(IProductFeedbackListView1 view) {
        this.view = view;
        this.model = new ProductFeedbackListModel1();
    }

    public void productFeedbackList() {
        view.showLoading();

        model.productFeedbackList(new ProductFeedbackListModel1.OnProductFeedbackListListener() {
            @Override
            public void getDataSuccessed(final List<WorkPartFeedbackResponse> workPartFeedbackList,
                                         final List<WorkPartFeedbackResponse> workPartFeedbackList_status_wait_confirm,
                                         final List<WorkPartFeedbackResponse> workPartFeedbackList_status_wait_reply,
                                         final List<WorkPartFeedbackResponse> workPartFeedbackList_status_confirm_finish,
                                         final List<WorkPartFeedbackResponse> workPartFeedbackList_status_success) {

                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductFeedbackListSuccessed(workPartFeedbackList, workPartFeedbackList_status_wait_confirm, workPartFeedbackList_status_wait_reply, workPartFeedbackList_status_confirm_finish, workPartFeedbackList_status_success);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getFailed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.showProductFeedbackListFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
